<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <!-- 注意:如果props里面是驼峰标识，要以下写法才能接受数据 -->
        <cpn :c-info='info' :c-message='message'></cpn>
    </div>

    <template id="cpn">
        <div>
            <ul>
                <li v-for='(item,index) in cInfo'>{{item}}</li>
            </ul>
            <h2>{{cMessage}}</h2>
        </div>
    </template>

    <script src='../js/vue.js'></script>
    <script>
        const cpn = {
            template: '#cpn',
            props: {
                cInfo: {
                    type: Object,
                    //数组和对象的默认值都是一个函数
                    default() {
                        return {}
                    }
                },
                cMessage: {
                    type: String,
                    default: '数据接收异常!'
                }
            }
        }

        const app = new Vue({
            el: '#app',
            data: {
                info: {
                    name: '张胜男',
                    gender: '男',
                    age: 22
                },
                message: '重庆对外经贸学院欢迎您!'
            },
            components: {
                cpn
            },
            methods: {

            }
        })
    </script>
</body>

</html>